package com.kws.merchant.controller;


import com.kws.common.config.constant.MinioCommonBucket;
import com.kws.merchant.domain.MerchantAwards;
import com.kws.merchant.service.MerchantAwardsService;
import com.kws.merchant.util.FileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import com.kws.common.core.domain.R;

import javax.annotation.Resource;
import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * 商家-奖项(MerchantAwards)表控制层
 *
 * @author yxy
 * @since 2024-11-01 09:43:21
 */
@RestController
@Api(tags = "商家-奖项(MerchantAwards)")
@RequestMapping("merchantAwards")
public class MerchantAwardsController {
    @Value("${minio.ENDPOINT}")
    private String minioUrl;
    /**
     * 服务对象
     */
    @Resource
    private MerchantAwardsService merchantAwardsService;
 
    @PostMapping("/page")
    @ApiOperation(value = "查询商家奖项")
    public R<Page<MerchantAwards>> pageList(@RequestBody com.kws.merchant.domain.po.Page page){
        return R.ok(merchantAwardsService.pageList(page));
    }

    @GetMapping("/detailById/{id}")
    @ApiOperation(value = "通过主键查询单条数据")
    public R<MerchantAwards> detailById(@PathVariable Long id) {
        MerchantAwards merchantAwards = merchantAwardsService.getById(id);
        merchantAwards.setFile(FileUtil.fixFileName()+merchantAwards.getFile());
        return R.ok();
    }


    @PostMapping("/addMerchantAwards")
    @ApiOperation("商家奖项新增")
    public R addMerchantAwards(@RequestBody MerchantAwards merchantAwards){
        return R.ok(merchantAwardsService.addMerchantAwards(merchantAwards));
    }

  /*  @PostMapping("/update")
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody MerchantAwards merchantAwards) {
        return R.ok(merchantAwardsService.updateById(merchantAwards));
    }*/


    @PostMapping("/delete")
    @ApiOperation(value = "删除数据")
    public R delete(@RequestBody List<Long> idList) {
        return R.ok(merchantAwardsService.removeByIds(idList));
    }


}
